package com.bcu.calculus.controller;

import com.bcu.calculus.entity.Message;
import com.bcu.calculus.entity.UserInfo;
import com.bcu.calculus.entity.UserInfoBranch;
import com.bcu.calculus.mapper.UserinfoMapper;
import com.bcu.calculus.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "12  用户信息模块")
@RestController
@RequestMapping("/api/userinfo")
public class UserInfoController {

    @Resource
    private UserInfoService userInfoService;

    @ApiOperation(value = "添加用户信息")
    @PostMapping(value = "/insert")
    public Message insertUserInfo(UserInfo userInfo){
        return userInfoService.AddUserInfo(userInfo);
    }

    @ApiOperation(value = "更新用户信息")
    @PutMapping(value = "/update")
    public Message updateUserInfo(UserInfo userInfo){
        return userInfoService.updateUserInfoByPrimaryKeySelective(userInfo);
    }

    @ApiOperation(value = "删除用户信息")
    @DeleteMapping(value = "/delByUserId")
    public Message delUserInfo(String userId){
        return userInfoService.deleteUserInfo(userId);
    }

    @ApiOperation(value = "获取所有的用户信息")
    @GetMapping(value = "/getall")
    public Message<List<UserInfo>> findAllUserInfo(){
        return userInfoService.findAllUserInfo();
    }

    @ApiOperation(value = "通过Id获取用户信息")
    @GetMapping(value = "/getone")
    public Message<UserInfo> getOneUserInfo(String userId){
        return userInfoService.selectUserInfoByUserId(userId);
    }

    @ApiOperation(value = "姓名模糊查询")
    @GetMapping(value = "selectByUserName")
    public Message<List<UserInfo>> selectByUserName(String userName){
        return userInfoService.slectByUserName(userName);
    }

  /*  @ApiOperation(value = "通过党小组查看平均分")
    @GetMapping(value = "/selectAvgScoreByUserBranch")
    public Message<List<UserInfo>> selectAvgScoreByUserBranch(Integer userBranch){
        return userInfoService.selectAvgScoreByUserBranch(userBranch);
    }

    @ApiOperation(value = "通过党小组查看及格率")
    @GetMapping(value = "/selectPRByUserBranch")
    public Message<List<UserInfo>> selectPRByUserBranch(Integer userBranch){
        return userInfoService.selectPRByUserBranch(userBranch);
    }

    @ApiOperation(value = "得到每个党小组及格率")
    @GetMapping(value = "/selectAllBranchPR")
    public Message<List<UserInfo>> selectAllBranchPR(){
        return userInfoService.selectAllBranchPR();
    }

    @ApiOperation(value = "得到每个党小组平均分")
    @GetMapping(value = "/selectALLBranchAvgScore")
    public Message<List<UserInfo>> selectALLBranchAvgScore(){
        return userInfoService.selectALLBranchAvgScore();
    }

    @ApiOperation(value = "得到党支部及格率")
    @GetMapping(value = "/selectAllPR")
    public Message<List<UserInfo>> selectAllPR(){
        return userInfoService.selectAllPR();
    }

    @ApiOperation(value = "得到党支部平均分")
    @GetMapping(value = "/selectAllAV")
    public Message<List<UserInfo>> selectAllAV(){
        return userInfoService.selectAllAV();
    }*/

//    @ApiOperation(value = "showSend")
//    @GetMapping(value = "/showSend")
//    public Message<List<UserInfo>> showSend(String flistId, String slistId, String tlsitId,String sendSemseterId){
//        return userInfoService.showSend(flistId,slistId,tlsitId,sendSemseterId);
//    }
}
